package com.Ajava1801D.并发包.cyclicreby;

import java.util.concurrent.CyclicBarrier;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2020/10/7  15:31
 * 描述:
 */
public class TestCyc implements Runnable {

    private CyclicBarrier cyclicBarrier;

    private int dens;

    public TestCyc(CyclicBarrier cyclicBarrier, int dens) {
        this.cyclicBarrier = cyclicBarrier;
        this.dens = dens;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(dens*1000);
            System.out.println("==============="+Thread.currentThread().getName()+"====就位");
            cyclicBarrier.await();
            System.out.println("============"+Thread.currentThread().getName()+"====起跑");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
